package com.example.app.pages.main.home.addNew.addRecord.MyModalBottomSheetPlacePicker

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.SheetState
import androidx.compose.material3.SheetValue
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
import com.example.app.components.MyIcon.MyDownIcon
import com.example.app.components.MyModalBottomSheet.MyModalBottomSheetCustomTopBarAndBottomBar
import com.example.app.components.MyText.MyText
import com.example.app.pages.main.home.me.viewModel.AddNewViewModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MyModalBottomSheetPlacePicker(
        addNewViewModel: AddNewViewModel,
        showState: MutableState<Boolean>
) {
    var density = LocalDensity.current
    var show by remember {
        showState
    }
    //这个是bottomSheet的state
    var sheetState = SheetState(
        initialValue = SheetValue.Hidden,
        density = density,
        skipPartiallyExpanded = true //这个初始化是为了，一打开就是全部高度，不用再滑到顶部，限制滑动到顶部
    )
    var windowHeight = with(density) {
        LocalConfiguration.current.screenHeightDp
    }.dp
    if (show) {
        MyModalBottomSheetCustomTopBarAndBottomBar(
            sheetState = sheetState,
            topBarActions = {},
            topBarTitle = {
                MyText(text = "选择地点")
            },
            topNavigationIcon = {
                MyDownIcon(modifier = Modifier.clickable {
                    show = false
                })
            },
            onDismissRequest = {
                show = false
            },
            content = {
                Box(
                    modifier = Modifier.height(windowHeight)
                ) {
                }
            },
            bottomAppBarContent = {
            },
        )
    }
}